package connect

import (
	"net/http"
	"time"

	"github.com/zeromicro/go-zero/core/logx"
)

var Client = &http.Client{
	Transport: &http.Transport{
		DisableKeepAlives: true,
	},
	Timeout: 2*time.Second,
}

// Get 判断url是否能请求通
func Get (url string) bool {
	res,err :=Client.Get(url)
	if err != nil {
		logx.Errorw("connect error",logx.LogField{
			Key:   "error",
			Value: err.Error(),
		})
		return false
	}
	defer res.Body.Close()
	return res.StatusCode == http.StatusOK
}
